﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>切换用户</title>
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../../Scripts/easyUI145/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <link href="../../Comm/fonts/font-icons.min.css" rel="stylesheet" />
    <script src="../../Portal/layui/layui.js"></script>
    <script src="../../Scripts/layui/LayuiDialog.js"></script>
    <script src="../../Scripts/layui/layui/layui.js"></script>
    <link href="../../Scripts/layui/layui/css/layui.css" rel="stylesheet" />

    <style>
        .bg_color {
            background: #f6f6f6;
        }

        .title-center {
            text-align: center;
            color: #393939;
            background: #fff;
            font-weight: bold;
            height:41px;
        }

        .title-center-nobold {
            text-align: center;
            color: #393939;
            background: #fff;
            font-weight: 500;
            height: 41px;
        }

        .title-content {
            padding: 8px 25px;
        }
        /* 头部内容 */
        .top_content {
            display: flex;
            margin: 0px 35px;
            height: 40px;
            background: white;
            line-height: 40px;
            border-radius: 5px;
        }

            .top_content div {
                margin: 0 10px
            }

            .top_content .top_example {
                font-weight: 700;
            }
        /* 第一个表格布局 */
        #gwf, #gwls {
            margin: 10px 35px;
            background: #fff;
            padding-bottom: 15px;
            border-radius: 10px;
        }

        .add_line::before {
            content: '';
            margin-left: -10px;
            margin-right: 5px;
            border-left: 5px solid #0237a1;
        }

        .content_color {
            color: #666;
            background: #f6f6f6;
            border: 1px solid #fff;
        }
        .layui-btn{
            border-radius:5px;
        }
        .layui-btn-normal {
            background: #0237a1;
        }
    </style>
    <script language="javascript" type="text/javascript">

        var flowNo = GetQueryString("FK_Flow");
        var workID = GetQueryString("WorkID");
        var userNo = GetQueryString("UserNo");
        var token = GetQueryString("Token") || GetQueryString("Token");

        var tester = GetQueryString("Tester");


        //页面启动函数.
        $(function () {

            if (token == null || userNo == undefined) {
                alert("没有找到，Token, 请确认上一步操作的问题. ");
                return;
            }

            if (workID == 0 || workID == undefined) {
                alert("丢失了workid.");
                return;
            }

            var gwf = new Entity("BP.WF.GenerWorkFlow", workID);
            var adminToken = GetQueryString("AdminToken") || localStorage.getItem("AdminToken");
            //访问后台，获得一个工作ID.
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_TestingContainer");
            handler.AddPara("Token", adminToken);
            handler.AddPara("UserNo", GetQueryString("UserNo"));
            handler.DoMethodReturnString("Default_LetAdminerLogin");
            window.parent.InitPageUserInfo(adminToken);

            handler.AddUrlData();
            var ens = handler.DoMethodReturnJSON("SelectOneUser_Init");

            //   var webUser = new WebUser();
            //    $("#userInfo").html("<h3>用户信息：<font color=green>" + webUser.No + "," + webUser.Name + " </font> 部门编号:<font color=green>" + webUser.FK_Dept + "</font> 部门名称: <font color=green>" + webUser.FK_DeptName + "</font></h3>");

            var html = "<table style='width:93%;margin:15px;'>";
            html += "<caption style='color:#000;margin-top: 20px;' class='add_line'>工作人员列表</caption>";
            html += "<tr>";
            html += "<th class='title-center'>Idx</th>";
            html += "<th class='title-center' >人员编号</th>";
            html += "<th class='title-center' >名称</th>";
            html += "<th class='title-center' >节点ID</th>";
            html += "<th class='title-center' >节点名称</th>";
            html += "<th class='title-center' >下达时间</th>";
            html += "<th class='title-center' >处理时间</th>";

            html += "<th class='title-center' >是否读取？</th>";
            html += "<th class='title-center' >IsPass状态</th>";
            html += "<th class='title-center' >操作</th>";

            // html += "<th>操作</th>";
            html += "</tr>";

            for (var i = 0; i < ens.length; i++) {
                var en = ens[i];

                if (en.IsPass == 0) {
                    html += "<tr class=Sum>";
                } else {
                    html += "<tr >";
                }

                html += "<td class='title-center-nobold ' >" + i + "</td>";
                html += "<td class='title-center-nobold '>" + en.FK_Emp + "</td>";
                html += "<td class='title-center-nobold '>" + en.EmpName + "</td>";
                html += "<td class='title-center-nobold '>" + en.FK_Node + "</td>";
                html += "<td class='title-center-nobold '>" + en.NodeName + "</td>";

                html += "<td class='title-center-nobold '>" + en.RDT + "</td>";

                if (en.IsPass == 0) {
                    html += "<td class='title-center-nobold '> - </td>";
                } else {
                    html += "<td class='title-center-nobold '>" + en.CDT + "</td>";
                }
                if (en.IsRead == 0) {
                    html += "<td class='title-center-nobold '>" + '未读' + "</td>";
                } else {
                    html += "<td class='title-center-nobold '>" + '已读' + "</td>";
                }

                if (en.IsPass == 0 && en.FK_Node == gwf.FK_Node) {
                    html += "<td class='title-center-nobold'><b><font color=green>" + en.IsPass + "-待办</font></b></td>";
                    html += "<td class='title-center-nobold '><a href=\"javascript:ChangUser('" + en.FK_Emp + "','" + en.FK_Node + "','" + en.WorkID + "','" + en.FID + "')\">切换用户</a><br/></td>";
                } else if (en.IsPass == 0 && en.FID != 0) {
                    html += "<td class='title-center-nobold '><b><font color=green>" + en.IsPass + "待办</font></b></td>";
                    html += "<td class='title-center-nobold '><a href=\"javascript:ChangUser('" + en.FK_Emp + "','" + en.FK_Node + "','" + en.WorkID + "','" + en.FID + "')\">切换用户</a><br/></td>";

                } else if (en.IsPass == -2) {
                    html += "<td class='title-center-nobold '>分流</td>";
                    html += "<td class='title-center-nobold'> - </td>";
                }
                else if (en.IsPass == 3) {
                    html += "<td class='title-center-nobold '><font color=red>未到达</font></td>";
                    html += "<td class='title-center-nobold '> - </td>";
                } else {
                    html += "<td class='title-center-nobold '>已处理</td>";
                    html += "<td class='title-center-nobold '> - </td>";
                }
                html += "</tr>";
            }

            html += "</table>";
            $("#gwls").html(html);
            $("tr:odd td").addClass("content_color");  //隔行换色



            //******************************** 绑定流程信息 **/
            var gwf = new Entity("BP.WF.GenerWorkFlow", workID);
            var html = "<table table table-bordered  style='width:93%;margin: 35px 15px 25px 15px;'>";   //style = 'width:900px;'
            html += "<caption style='color:#000;margin-top: 20px;' class='add_line'>流程信息</caption>";
            html += "<tr>";
            html += "<th class='title-center'>标题</th>";
            html += "<td colspan=6 class='title-content' >" + gwf.Title + "</td>";
            html += "</tr>";

            html += "<tr>";
            html += "<th class='title-center'>工作ID</th>";
            html += "<td class='title-content'>" + gwf.WorkID + "</td>";
            html += "<th class='title-center'>状态</th>";
            html += "<td class='title-content'>" + GetWFState(gwf.WFState) + "</td>";
            html += "<th class='title-center'>发起人</th>";
            html += "<td class='title-content'>" + gwf.Starter + "," + gwf.StarterName + "</td>";
            html += "</tr>";

            html += "<tr>";
            html += "<th class='title-center'>停留节点ID</th>";
            html += "<td class='title-content'>" + gwf.FK_Node + "," + gwf.NodeName + "</td>";
            html += "<th class='title-center'>当前待办人员</th>";
            html += "<td class='title-content'>" + gwf.TodoEmps + "</td>";
            html += "<th class='title-center'>流程名称</th>";
            html += "<td class='title-content'>" + gwf.FlowName + "</td>";

            //html += "<td colspan=2 class='title-content'> <b>";
            //html += "<a href='javascript:Skip();' >实例运维：跳转-调整-删除-移交-强制结束</a></b>";
            //html += "</td>";

            html += "</table>";
            $("#gwf").html(html);

        });

        function Skip() {
            var url = "../../Comm/En.htm?EnName=BP.WF.Data.GenerWorkFlowView&PKVal=" + workID + "&FK_Flow=" + GetQueryString("FK_Flow") + "&WFSta=all";
			OpenLayuiDialog(url, "实例运维", window.innerWidth, 100, "r", true);
        }

        function ChangUser(empNo, nodeID, workid, fid, isMobile) {

            //当这个人登录。
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_TestingContainer");
            handler.AddPara("FK_Emp", empNo);
            handler.AddPara("WorkID", workid);
            handler.AddPara("FID", fid);

            var adminer = GetQueryString("Adminer");
            handler.AddPara("Adminer", adminer);

            var AdminerToken = GetQueryString("AdminerToken") || localStorage.getItem("AdminToken");
            handler.AddPara("AdminerToken", AdminerToken);

            var orgNo = GetQueryString("OrgNo");

            var webUser = new WebUser();

            if (orgNo != webUser.OrgNo) {
                alert(" 系统错误: " + orgNo + " curr:" + webUser.OrgNo + ", 出现了组织结构编号不一致.");
                return;
            }
            handler.AddPara("OrgNo", orgNo);

            var data = handler.DoMethodReturnString("SelectOneUser_ChangUser");
            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }
            localStorage.setItem("Token", data);
            if (isMobile == 1)
                window.open('../../../CCMobile/MyFlow.htm?Token=' + data + '&FK_Flow=' + flowNo + '&WorkID=' + workid + "&FID=" + fid + "&FK_Node=" + nodeID, '_self');
            else
                window.open('../../MyFlow.htm?Token=' + data + '&FK_Flow=' + flowNo + '&WorkID=' + workid + "&FID=" + fid + "&FK_Node=" + nodeID, '_self');


            window.parent.InitPageUserInfo(data);
        }

        function GetWFState(wfstate) {
            switch (parseInt(wfstate)) {
                case 0:
                    return "<font color='black'>空白</font>";
                case 1:
                    return "<font color='black'>草稿</font>";
                case 2:
                    return "<font color='#d9b653' style='font-weight:bolder;'>运行中</font>";
                case 3: //已完成.
                    return "<font color='green' style='font-weight:bolder;'>已完成</font>";
                case 4:
                    return "<font color='black'>挂起</font>";
                case 5:
                    return "<font color='red' style='font-weight:bolder;'>退回</font>";
            }
        }

        function OpenRpt() {
            var url = "../../WFRpt.htm?WorkID=" + workID + "&FK_Flow=" + flowNo;
            WinOpen(url);
        }
    </script>
</head>
<body class="bg_color">

    <h4 style="text-align:center">

        <!--| <a href="javascript:Skip();">回滚</a>-->
    </h4>
    <div id="userInfo"></div>

    <center>
        <div class="top_content">
            <div class="top_example"><i class="icon-plane" style="font-weight:700;"></i> 流程测试容器\\实例运维：</div>
            <div><button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick='javascript:Skip();'>跳转</button></div>
            <div><button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick='javascript:Skip();'>调整</button>  </div>
            <div><button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick='javascript:Skip();'>删除</button>  </div>
            <div><button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick='javascript:Skip();'>移交</button> </div>
            <div><button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick='javascript:Skip();'>强制结束</button> </div>
        </div>
        <div id="gwf"></div>

        <div id="gwls"></div>

    </center>
</body>
</html>